<template>
    <div style="margin-left: 150px">
            姓名:<el-input style="width:250px" v-model="param.uName" placeholder="请输入内容"></el-input><br>
            密码:<el-input style="width:250px" v-model="param.uPwd" placeholder="请输入内容"></el-input><br>
            确认密码:<el-input style="width:250px" v-model="param.newPwd" placeholder="请输入内容" @blur="sure()"></el-input><br>
            上传头像： <input type="file" @change="getFile($event)" style="margin-top:100px;margin-left:100px" >
               <el-button type="primary" style="margin-top:15px" icon="el-icon-user-solid"  @click="add">添加</el-button>
        </div>
</template>

<script>
export default {
      data(){
        return {
            param:{},
         
        }
    },
     methods:{
         async add(){
              if(this.sure() == true){
            var cutObj = await this.ajax.uploadSubmit("/project/users",this.param)
            if(cutObj == "ok"){
                alert("添加成功");
                 this.$router.push("/list");
            } 
            } else{
                alert("两次密码不一致，请重新输入")
            }
        },
              sure(){
            //  alert("a")
            if(this.param.uPwd != this.param.newPwd){
                alert("密码不一致")
                return false
            }
            else{
                return true
            }
        },
          getFile(event){
             //得到文件表单的dom对象
          this.param.file= event.target.files[0];
          event.preventDefault();

       
        
        }
     }
}
</script>

<style>

</style>